package org.credo.thread;

public class Thread_yield extends Thread{

	public static void main(String[] args) {
		//启动2个并发线程
		Thread_yield ty1=new Thread_yield("Super A--");
		Thread_yield ty2=new Thread_yield("Super B--");
		ty1.start();
		ty2.start();
	}
	
	public Thread_yield(String name){
		super(name);
	}
	
	public void run(){
		for(int i=0;i<50;i++){
			System.out.println(getName()+" "+i);
			if(i==20){
				Thread.yield();
				System.out.println("====================");
			}
		}
	}
}
